#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;

class Solution {
public:
    bool dp[1010][1010];
    string longestPalindrome(string s) {
        // memset(dp, false, sizeof(dp));
        int n = s.size();
        if (n == 1) return s;

        int res = 1, resl = 0, resr = -1;
        for (int i = 0; i < n; i++) dp[i][i] = true;

        for (int l = 2; l < n; l++) {
            for (int i = 0; i+l-1 < n; i++) {
                int j = i+l-1;
                cout << i << ',' << j << endl;
                if (s[i] == s[j]) {
                    dp[i][j] = dp[i+1][j-1];
                    if (i+1 == j) dp[i][j] = true;
                    if (dp[i][j]) {
                        if (l > res) {
                            res = l, resl = i, resr = j;
                        }
                    }
                }
            }
        }

        return s.substr(resl, res);
    }
};

int main() {
// #ifdef LOCAL
//     freopen("in.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
// #endif
    ios::sync_with_stdio(false), cin.tie(0);
    string s = "bb";
    Solution so;
    cout << so.longestPalindrome(s) << endl;
    return 0;
}

